#!/bin/sh
#Filename: crmserver-restart.sh
#Description：crm服务重启脚本

if [ ! -n "$1" ] ;then
    echo "请输入版本号!"
    exit
fi

version=$1
service=$2
sourcebase="/home/jingle"
basedir="/home/dockerfile/jingle"


#更新编译
# cd ${sourcebase}
# git pull 
# mvn clean package -Dmaven.test.skip=true


echo "拷贝jar文件到当前目录..."
cp "${sourcebase}/${version}/crm-server/crm-work/target/crm-work-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-callcenter/target/crm-callcenter-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-customer/target/crm-customer-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-config/target/crm-config-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-pms/target/crm-pms-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-location/target/crm-location-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-charge/target/crm-charge-${version}.jar" "${basedir}/${version}/"
cp "${sourcebase}/${version}/crm-server/crm-security/target/crm-security-${version}.jar" "${basedir}/${version}/"

cd ${basedir}

#项目名称 镜像和容器名字都前都会追加该名字
export COMPOSE_PROJECT_NAME=${version}
docker-compose up --build -d ${service}